package lab03.test11;

import java.sql.*;

public class Test11 {
    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "123456"
            );

            statement = connection.createStatement();

            String sql = "insert into t_users(username,password,register_datetime) value('admin','admin',192312312123)";
            statement.execute(sql);
            String sql2 = "insert into t_users(username,password,register_datetime) value('chen','123456',123123213123)";
            statement.execute(sql2);

//            System.out.println("遍历:");
//            resultSet = statement.executeQuery("SELECT * FROM t_users");
//            while(resultSet.next()){
//                System.out.print(resultSet.getInt(1)+" \t");
//                System.out.print(resultSet.getString(2)+" \t");
//                System.out.print(resultSet.getString(3)+" \t");
//                System.out.print(resultSet.getInt(4)+" \t");
//                System.out.println();
//            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
